package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoJugador extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JPanel panListadoJugador;
	private JLabel lblSeleccione;
	private JButton btnSalir;
	private JComboBox cmbNivel;
	private JScrollPane scpListadoJugador;
	private JTable tblJugador;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	private static VentanaListadoJugador instancia;

	public final static synchronized VentanaListadoJugador getInstancia() {
		if (instancia == null)
			instancia = new VentanaListadoJugador();
		return instancia;
	}
		
	public VentanaListadoJugador() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				panListadoJugador = new JPanel();
				getContentPane().add(panListadoJugador, BorderLayout.CENTER);
				panListadoJugador.setLayout(null);
				{
					lblSeleccione = new JLabel();
					panListadoJugador.add(lblSeleccione);
					lblSeleccione.setText("Seleccione un Nivel");
					lblSeleccione.setBounds(36, 28, 156, 25);
				}
				{
					scpListadoJugador = new JScrollPane();
					panListadoJugador.add(scpListadoJugador);
					scpListadoJugador.setBounds(36, 79, 443, 226);
					{
						TableModel tblJugadorModel = 
							new DefaultTableModel();
						tblJugador = new JTable();
						scpListadoJugador.setViewportView(tblJugador);
						tblJugador.setModel(tblJugadorModel);
					}
				}
				{
					ComboBoxModel cmbNivelModel = 
						new DefaultComboBoxModel();
					cmbNivel = new JComboBox();
					panListadoJugador.add(cmbNivel);
					cmbNivel.setModel(cmbNivelModel);
					cmbNivel.setBounds(186, 27, 146, 26);
				}
				{
					btnSalir = new JButton();
					panListadoJugador.add(btnSalir);
					btnSalir.setText("Salir");
					btnSalir.setBounds(209, 332, 81, 31);
				}
			}
			pack();
			this.setSize(532, 420);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void addListener(ActionListener actionListener) {
		this.cmbNivel.addActionListener(actionListener);
		this.btnSalir.addActionListener(actionListener);
	}
	
	public void setResultados(AbstractTableModel abstractTableModel) {
		tblJugador.setModel(abstractTableModel);
	}
	
	public JComboBox getComboNivel() {
		return this.cmbNivel;
	}
	
	public void cargarComboNivel(Vector<String> vector){
		ComboBoxModel cmbNivelModel = 
			new DefaultComboBoxModel(vector);
		cmbNivel.setModel(cmbNivelModel);
	}
	
	public String getComboNivelSeleccionado() {
		return this.cmbNivel.getSelectedItem().toString();
	}

}
